#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>

double calculateAverage(const std::vector<int>& nums) {
    double sum = 0;
    for (int num : nums) {
        sum += num;
    }
    return sum / nums.size();
}

double calculateMedian(std::vector<int>& nums) {
    std::sort(nums.begin(), nums.end());
    int n = nums.size();
    if (n % 2 == 0) {
        return (nums[n/2 - 1] + nums[n/2]) / 2.0;
    } else {
        return nums[n/2];
    }
}

int calculateMode(const std::vector<int>& nums) {
    std::unordered_map<int, int> frequency;
    for (int num : nums) {
        frequency[num]++;
    }
    int mode = nums[0];
    int max_count = 0;
    for (const auto& pair : frequency) {
        if (pair.second > max_count) {
            max_count = pair.second;
            mode = pair.first;
        }
    }
    return mode;
}

int main() {
    int num_students;
    std::cout << "调查了多少个学生: ";
    std::cin >> num_students;
    
    std::vector<int> movies(num_students);
    std::cout << "输入每个学生所看过的电影数量: ";
    for (int i = 0; i < num_students; ++i) {
        std::cin >> movies[i];
    }
    
    double average = calculateAverage(movies);
    double median = calculateMedian(movies);
    int mode = calculateMode(movies);
    
    std::cout << "平均值: " << average << std::endl;
    std::cout << "中值: " << median << std::endl;
    std::cout << "众数: " << mode << std::endl;
    
    return 0;
}